$(function()
			{
				$("#gridTable").jqGrid({
					url:'servlet/MainServlet',
					datatype: "json",
					mytype:'post',
					height: 250,
					colNames:['编号','用户名', '性别', '邮箱', 'QQ','手机号','出生日期'],
					colModel:[
						{name:'id',index:'id', width:60, sorttype:"int"},
						{name:'userName',index:'userName', width:90},
						{name:'gender',index:'gender', width:90},
						{name:'email',index:'email', width:125,sorttype:"string"},
						{name:'QQ',index:'QQ', width:100},		
						{name:'mobilePhone',index:'mobilePhone', width:120},		
						{name:'birthday',index:'birthday', width:100, sorttype:"date"}
					],
					sortname:'id',
					sortorder:'asc',
				//	prmNames: {search: "search"},
					viewrecords:true,
					rowNum:10,
					rowList:[10,20,30],
					jsonReader:
						{
						repeatitems : false
					},
					pager:"#gridPager",
					caption: "jqGrid与Servlet集成"
			}).navGrid('#gridPager',{edit:false,add:false,del:false});
		})
		
		
var echoSelRow = function() {
	var id = $("#gridTable").jqGrid("getGridParam", "selrow");
	
	alert("当前选中行ID：" + id);
};
var getContact = function() {
	var selectedId = $("#gridTable").jqGrid("getGridParam", "selrow");
	
	var rowData = $("#gridTable").jqGrid("getRowData", selectedId);
	
	alert("Name: " + rowData.userName);
};
var addContact = function() {
	var selectedId = $("#gridTable").jqGrid("getGridParam", "selrow");
	
	var dataRow = {	
		id : 99,
		userName : "cx",
		gender : "女",
		email : "zhang_san@126.com",
		QQ : "424234324",
		mobilePhone : "34234",
		birthday : "1991-11-29"
	};
	
	if (selectedId) {
		$("#gridTable").jqGrid("addRowData", 99, dataRow, "before", selectedId);
		
	} else {
		$("#gridTable").jqGrid("addRowData", 99, dataRow, "first");
		
	}
};
var updateContact = function() {
	var selectedId = $("#gridTable").jqGrid("getGridParam", "selrow");
	
	var dataRow = {
		userName : "xsc",
		email : "li_si@126.com" 
	};
	
	var cssprop = {
		color : "#FF0000"
	};
	
	$("#gridTable").jqGrid('setRowData', selectedId, dataRow, cssprop);
};
var deleteContact = function() {
	var selectedId = $("#gridTable").jqGrid("getGridParam", "selrow");
	
	$("#gridTable").jqGrid('delRowData', selectedId);
};
var changeGridOptions = function() {
	$("#gridTable").jqGrid("setGridParam", {
		rowNum: 50,
		page: 16
	}).trigger('reloadGrid');
	
	$("#gridTable").jqGrid("setCaption", "Contact List").trigger('reloadGrid');
	
	alert($("#gridTable").jqGrid("getGridParam", "caption"));
	alert($("#gridTable").jqGrid("getGridParam", "rowNum"));
};
var resetWidth = function() {
	$("#gridTable").jqGrid("setGridWidth", 300, false);
};
		//?_search=false&nd=1332778322226&rows=10&page=1&sidx=id&sord=asc